package com.atguigu.controller;

import com.atguigu.entity.Admin;
import com.atguigu.entity.Permission;
import com.atguigu.service.AdminService;
import com.atguigu.service.PermissionService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Date:2022/10/29
 * Author:ybc
 * Description:
 */
@Controller
public class FrameController {

    @DubboReference
    private PermissionService permissionService;
    @DubboReference
    private AdminService adminService;


    @RequestMapping("/")
    public String index(Model model){
        Long adminId = 1L;
        //根据用户名查询用户信息
        Admin admin = adminService.getById(adminId);
        //查询用户的权限列表
        List<Permission> permissionList = permissionService.findPermissionListByAdminId(admin.getId());
        model.addAttribute("admin",admin);
        model.addAttribute("permissionList",permissionList);
        return "frame/index";
    }

    @RequestMapping("/main")
    public String main(){
        return "frame/main";
    }

}
